#!/usr/bin/env python
# -*- coding:utf-8 -*-
from django import forms
import json
from app01 import models

class ImportForm(forms.Form):
    HOST_TYPE_LIST = (
        (1,'物理机'),
        (2,'虚拟机')
    )
    host_type=forms.IntegerField(
        widget=forms.Select(choices=HOST_TYPE_LIST)
    )
    hostname = forms.CharField()

###########################admin行:管理员############################
    # fr  = open('db_admin')
    # data = fr.read()
    # data_tuple = json.loads(data)
    # fr.close()
    #
    # admin = forms.IntegerField(
    #     widget=forms.Select(choices=data_tuple)
    # )
    admin = forms.IntegerField(
        widget=forms.Select()
    )
    def __init__(self,*args,**kwargs):
        super(ImportForm,self).__init__(*args,**kwargs)
        # fr = open('db_admin')
        # data = fr.read()
        # data_tuple = json.loads(data)
        self.fields['admin'].widget.choices = models.SimpleModel.objects.all().values_list('id','username')

